//--------------------------------------------------------------------------------
// This file is a portion of the D2D1Renderer.  It is distributed
// under the MIT License, available in the root of this distribution and 
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Mirco Timmermann
//
//--------------------------------------------------------------------------------
#include "Point2f.h"


Point2f::Point2f() {
	this->x = 0;
	this->y = 0;
}

Point2f::Point2f(float x, float y) {
	this->x = x;
	this->y = y;
}

Point2f::Point2f(const Point2f &v) {
	x = v.x;
	y = v.y;
}

Point2f::~Point2f(void) {

}

Point2f Point2f::operator * (const Point2f &v) const {
	return Point2f(x * v.x, y * v.y);
}

Point2f Point2f::operator / (const Point2f &v) const {
	return Point2f(x / v.x, y / v.y);
}

Point2f Point2f::operator + (const Point2f &v) const {
	return Point2f(x + v.x, y + v.y);
}

Point2f Point2f::operator - (const Point2f &v) const {
	return Point2f(x - v.x, y - v.y);
}

Point2f Point2f::operator * (float f) const {
	return Point2f(x * f, y * f);
}

Point2f Point2f::operator / (float f) const {
	float inv_f = 1.0f / f;
	return Point2f(x * inv_f, y * inv_f);
}

Point2f Point2f::operator + (float f) const {
	return Point2f(x + f, y + f);
}

Point2f Point2f::operator - (float f) const {
	return Point2f(x - f, y - f);
}

Point2f Point2f::operator - (void) const {
	return Point2f(-x, -y);
}

//

void Point2f::operator *= (const Point2f &v) {
	x *= v.x;
	y *= v.y;
}

void Point2f::operator /= (const Point2f &v) {
	x /= v.x;
	y /= v.y;
}

void Point2f::operator += (const Point2f &v) {
	x += v.x;
	y += v.y;
}

void Point2f::operator -= (const Point2f &v) {
	x -= v.x;
	y -= v.y;
}

void Point2f::operator *= (float f) {
	x *= f;
	y *= f;
}

void Point2f::operator /= (float f) {
	float inv_f = 1.0f / f;

	x *= inv_f;
	y *= inv_f;
}

//

bool Point2f::operator > (const Point2f &v) const {
	return (x > v.x) && (y > v.y);
}

bool Point2f::operator >= (const Point2f &v) const {
	return (x >= v.x) && (y >= v.y);
}

bool Point2f::operator < (const Point2f &v) const {
	return (x < v.x) && (y < v.y);
}

bool Point2f::operator <= (const Point2f &v) const {
	return (x <= v.x) && (y <= v.y);
}

bool Point2f::operator == (const Point2f &v) const
{
	return (x == v.x && y == v.y);
}

bool Point2f::operator != (const Point2f &v) const {
	return (x != v.x || y != v.y);
}

//

Point2f::operator float*() {
	return &x;
}

Point2f::operator const float*() const {
	return &x;
}

//

Point2f Point2f::xx() const {
	return Point2f(x, x);
}

Point2f Point2f::xy() const {
	return Point2f(x, y);
}

Point2f Point2f::yx() const {
	return Point2f(y, x);
}

Point2f Point2f::yy() const {
	return Point2f(y, y);
}